package com.pc.web.boardQnA;

import java.util.List;

import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.pc.web.board.BoardBeans;


@Repository
public class BoardQnADAO {
	@Autowired private SqlSession sql;
	//회원 글쓰기
	public int insert(BoardQnABeans beans){
		return sql.insert("boardQnA.insert", beans);
	}
	//리스트
	public List<BoardQnABeans> select(){
		return sql.selectList("boardQnA.select");
	}
	//글 상세보기
	public BoardQnABeans detailView(String boardQnA_no) {
		return sql.selectOne("boardQnA.detailView", boardQnA_no);
	}
	//글 수정상세보기
	public BoardQnABeans modifyView(String boardQnA_no) {
		return sql.selectOne("boardQnA.modifyView", boardQnA_no);
	}
	//글 업데이트
	public int update(BoardQnABeans beans) {
		return sql.update("boardQnA.modify", beans);
	}
	//글 삭제
	public void delete(String boardQnA_no) {
		sql.delete("boardQnA.delete", boardQnA_no);
	}
	//글 총수
	public int getListCount(){
		return sql.selectOne("boardQnA.listcount");
	}
	public List<BoardQnABeans> getBoardQnAList(BoardQnABeans beans){
		return sql.selectList("boardQnA.boardQnAlist", beans);
	}
	//조회수 업데이트
	public void countUpdate(String boardQnA_no){
		sql.update("boardQnA.countUpdate", boardQnA_no);
	}
	//댓글삭제
	public void commentDelete(String boardQnA_number){
		sql.delete("boardQnA.commentDelete", boardQnA_number);
	}
	//덧글입력
	public int commentInsert(BoardQnABeans beans){
		return sql.insert("boardQnA.comment", beans);
	}
	//댓글 리스트
	public List<BoardBeans> commentView(String boardQnA_no) {
		return sql.selectList("boardQnA.commentView", boardQnA_no);
	}
	//댓글 가져오기
	public List<String> commentList(String boardQnA_no){
		return sql.selectList("boardQnA.commentList", boardQnA_no);
	}
}